package com.cbs.java.component.network.decoder;


import okhttp3.ResponseBody;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;

/**
 * Created by broche on 10/20/15.
 */
public class ImageDecoder implements Decoder {
    @Override
    public Object decode(ResponseBody body) throws IOException {
        return ImageIO.read(body.byteStream());
    }

    @Override
    public String desc(Object result) {
        BufferedImage image = (BufferedImage) result;
        return String.format("bitmap: width=%d\theight=%d", image.getWidth(), image.getHeight());
    }
}
